<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:pm="http://primefaces.org/mobile" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>
		<ui:composition template="/admin/template.xhtml">
				<ui:define name="body">
						<style>
.fixcol120 {
	width: 120px;
}
</style>
						<h:form>
								<p:panel id="create-panel" header="创建新症状" style="margin-bottom:10px;">
										<p:messages id="create-messages" />
										<h:panelGrid columns="3" cellpadding="5" columnClasses="fixcol120">

												<p:outputLabel for="foodName" value="所属病种" />
												<p:selectOneMenu id="foodName" value="#{illnessCategory.id}" style="width: 300px;" required="true" valueChangeListener="#{detailCategoryController.onSelectedValueChanged}">
														<f:selectItems value="#{detailCategoryController.illNessCategoryList}" var="icType" itemLabel="#{icType.illnessName}" itemValue="#{icType.id}"></f:selectItems>
														<f:ajax render="subCateName"></f:ajax>
												</p:selectOneMenu>
												<h:outputText value="(病种可在病种管理中设定)"></h:outputText>

												<p:outputLabel for="subCateName" value="所属病症" />
												<p:selectOneMenu id="subCateName" value="#{detailCategoryController.selectedScType}" style="width: 300px;" required="true">
														<f:selectItems value="#{detailCategoryController.subCategoryList}" var="scType" itemLabel="#{scType.subCateName}" itemValue="#{scType.id}"></f:selectItems>
												</p:selectOneMenu>
												<h:outputText value="(病症可在病症管理中设定)"></h:outputText>

												<p:outputLabel for="price" value="症状描述" />
												<p:inputText id="price" required="true" value="#{detailCategory.detailCateName}" />
												<h:outputText value="(不超过45字)"></h:outputText>

												<p:outputLabel for="solution" value="症状副方" />
												<p:inputTextarea id="solution" required="true" value="#{detailCategory.detailSolution}" autoResize="true" cols="80"></p:inputTextarea>
												<h:outputText value="(不超过2000字)"></h:outputText>
										</h:panelGrid>

										<p:commandButton value="创建新症状" type="button" onclick="PF('cd').show()" />
										<p:commandButton value="重置" type="reset"></p:commandButton>
								</p:panel>

								<p:confirmDialog widgetVar="cd" header="操作确认" severity="info">
										<f:facet name="message">
												<h:outputText value="是否创建新症状" />
										</f:facet>
										<p:commandButton value="创建新症状" update="@form :query-list-form" oncomplete="PF('cd').hide()" actionListener="#{detailCategoryController.createInstance}" />
										<p:commandButton value="取消" type="button" onclick="PF('cd').hide()"></p:commandButton>
								</p:confirmDialog>
						</h:form>

						<h:form id="query-list-form">
								<p:panel id="query-panel" header="已有症状列表" style="margin-bottom:10px;">
										<p:dataTable id="table" var="bean" value="#{detailCategoryController.detailCategoryList}">

												<p:column headerText="ID" style="width: 30px">
														<h:outputText value="#{bean.id}" />
												</p:column>

												<p:column headerText="所属病种">
														<h:outputText value="#{bean.subCategory.illnessCategory.illnessName}" />
												</p:column>

												<p:column headerText="所属病症">
														<h:outputText value="#{bean.subCategory.subCateName}" />
												</p:column>

												<p:column headerText="症状描述">
														<h:outputText value="#{bean.detailCateName}" />
												</p:column>

												<p:column headerText="症状副方">
														<h:outputText value="#{bean.detailSolution}" />
												</p:column>

												<p:column headerText="操作" style="text-align: center; width: 140px;">
														<p:commandButton icon="ui-icon-document" value="修改" oncomplete="PF('modify-dlg').show()" process="@this" update=":query-list-form:modify-panel" actionListener="#{detailCategoryController.loadSelectedBean(bean.id)}">
																<f:setPropertyActionListener value="#{bean}" target="#{detailCategoryController.selectedBean}"></f:setPropertyActionListener>
														</p:commandButton>
												</p:column>
										</p:dataTable>
								</p:panel>
								<p:dialog widgetVar="modify-dlg" header="修改症状">
										<p:panel id="modify-panel" header="修改症状" style="margin-bottom:10px;">
												<p:messages id="modify-msgs" />
												<h:panelGrid columns="3" cellpadding="5">

														<p:outputLabel for="a1" value="所属病种" />
														<h:outputText id="a1" value="#{detailCategoryController.selectedBean.subCategory.illnessCategory.illnessName}"></h:outputText>
														<h:outputText value=""></h:outputText>
														
														<p:outputLabel for="a2" value="所属病症" />
														<h:outputText id="a2" value="#{detailCategoryController.selectedBean.subCategory.subCateName}"></h:outputText>
														<h:outputText value=""></h:outputText>

														<p:outputLabel for="foodName" value="症状描述" />
														<p:inputText id="foodName" required="true" value="#{detailCategoryController.selectedBean.detailCateName}" style="width: 400px" />
														<h:outputText value="(不超过45个字)"></h:outputText>

														<p:outputLabel for="solution" value="症状副方" />
														<p:inputTextarea id="solution" required="true" value="#{detailCategoryController.selectedBean.detailSolution}" autoResize="true" cols="80"></p:inputTextarea>
														<h:outputText value="(不超过2000字)"></h:outputText>
												</h:panelGrid>

												<p:commandButton value="修改症状信息" actionListener="#{detailCategoryController.updateInstance}" process="modify-panel" update="query-panel" oncomplete="PF('modify-dlg').hide()" />
												<p:commandButton value="取消" type="button" onclick="PF('modify-dlg').hide()"></p:commandButton>
										</p:panel>
								</p:dialog>
						</h:form>

				</ui:define>
		</ui:composition>
</h:body>
</html>